package com.amit.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class SearchContactAction  extends Action{
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		System.out.println("execute()-SearchContactAction");
		
		String result="SearchResults";
		
		//1.collect the data
		
		SearchContactForm scf=(SearchContactForm) form;
		
		
		String em=scf.getEmail();
	
		System.out.println(em);
		
		ContactTO cto=new  ContactTO();
		
		cto.setFname("amit");
		cto.setLname("yadav");
		cto.setEmail(em);
		cto.setPhone("1234");
		
		HttpSession hs=request.getSession();
		hs.setAttribute("CTO", cto);
		hs.setAttribute("EDIT", "FALSE");
		
		return mapping.findForward(result);
		
	
	}

}
